<!--
 * @Author: your name
 * @Date: 2021-09-16 09:30:15
 * @LastEditTime: 2021-09-16 10:37:25
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \briup\6-jQuery\day05\3-绘制线段.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>绘制线段</title>
    <script>
        window.onload = function() {
            //1.获取画布
            var canvas = document.querySelector("canvas");
            //2.获取画笔 上下文对象---->context
            var context = canvas.getContext("2d");

            //3.开始路径
            context.beginPath();
            //4.绘制线段起点
            context.moveTo(0, 0);
            //线段颜色
            context.strokeStyle = "blue";
            //5.绘制线段终点
            context.lineTo(100, 100);
            context.lineTo(200, 10);
            context.lineTo(300, 100);
            //6.闭合路径
            context.closePath();
            //7.绘制线段
            context.stroke(); //fill绘制填充图形


        }
    </script>
</head>

<body>
    <canvas width="400px" height="400px"></canvas>
</body>

</html>